#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'miniMaxSum' function below.
#
# The function accepts INTEGER_ARRAY arr as parameter.
#

def miniMaxSum(arr):
    # Write your code here
    # 分别输出 除去一个最大值之后的数组元素之和 及 除去一个最小值之后的数组元素之和
    maxlist = arr.copy()
    maxlist.remove(min(arr))
    minlist = arr.copy()
    minlist.remove(max(arr))
    print(str(sum(minlist))+' '+str(sum(maxlist)))

if __name__ == '__main__':

    arr = list(map(int, input().rstrip().split()))

    miniMaxSum(arr)
